home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_nub_h2oswitch.cog < prev    next >
Text File  |  1999-11-15  |  17KB  |  714 lines

  1. # Jones 3D Cog Script
  2. #
  3. # nub_h2oswitch2.cog
  4. #
  5. # [TL] [GGJ] [RT]
  6. #
  7. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  8. #
  9. # ===================================================================
  10. symbols
  11.  
  12. message    startup
  13. message    arrived
  14. message    activated
  15. message    entered
  16. message    taken
  17. message    timer
  18.  
  19. # ***** COGS ********************************************************
  20.  
  21. cog        lightningcog    # Cog which controls the lightning strikes.
  22.  
  23. # ***** LINKED GEOMETRY *********************************************
  24.  
  25. sector    trigger
  26.  
  27. sector    twater0        linkID=1    # Top water sectors.
  28. sector    twater1        linkID=1
  29. sector    twater2        linkID=1
  30. sector    twater3        linkID=1
  31. sector    twater4        linkID=1
  32. sector    twater5        linkID=1
  33. sector    twater6        linkID=1
  34. sector    twater7        linkID=1
  35.  
  36. surface    killSurf0    linkID=2
  37. surface    killSurf1    linkID=2
  38. surface    killSurf2    linkID=2
  39. surface    killSurf3    linkID=2
  40. surface    killSurf4    linkID=2
  41. surface    killSurf5    linkID=2
  42. surface    killSurf6    linkID=2
  43. surface    killSurf7    linkID=2
  44. surface    killSurf8    linkID=2
  45. surface    killSurf9    linkID=2
  46.  
  47. # ***** NO LINK GEOMETRY ********************************************
  48.  
  49. sector    currentSector    local
  50.  
  51. sector    bwater0            nolink    # Bottom water sectors.
  52. sector    bwater1            nolink
  53. sector    bwater2            nolink
  54. sector    bwater3            nolink
  55.  
  56. sector    ptsec0            nolink
  57. sector    ptsec1            nolink
  58. sector    ptsec2            nolink
  59.  
  60. sector    pbsec0            nolink
  61. sector    pbsec1            nolink
  62. sector    pbsec2            nolink
  63.  
  64. surface    surface0a        nolink    # Top water surface adjoins.
  65. surface    surface0b        nolink
  66. surface    surface0c        nolink
  67. surface    surface0d        nolink
  68. surface    surface0e        nolink
  69. surface    surface0f        nolink
  70. surface    surface0g        nolink
  71. surface    surface0h        nolink
  72. surface    surface0i        nolink
  73.  
  74. surface    surface1a        nolink    # Middle water surface adjoins.
  75. surface    surface1b        nolink
  76. surface    surface1c        nolink
  77. surface    surface1d        nolink
  78. surface    surface1e        nolink
  79. surface    surface1f        nolink
  80. surface    surface1g        nolink
  81. surface    surface1h        nolink
  82.  
  83. # ***** LINKED THINGS ***********************************************
  84.  
  85. thing    switchA            linkID=3 # Controls A paddles
  86. thing    switchB            linkID=3 # Controls B paddles
  87.  
  88. thing    paddleAtop        linkID=4
  89. thing    paddleAbottom    linkID=4
  90. thing    paddleBtop        linkID=4
  91. thing    paddleBbottom    linkID=4
  92.  
  93. thing    h2o                linkID=5 # Water surface 3do
  94.  
  95. thing    IMP4
  96.  
  97. # ***** NO LINK THINGS **********************************************
  98.  
  99. thing    camera0            nolink
  100. thing    camera1            nolink
  101.  
  102. thing    drainWater0        nolink
  103. thing    drainWater1        nolink
  104. thing    drainWater2        nolink
  105.  
  106. thing    origin0            nolink
  107. thing    origin1            nolink
  108. thing    origin2            nolink
  109. thing    origin3            nolink
  110.  
  111. thing    paddleTarget    nolink
  112.  
  113. thing    spicket            nolink
  114.  
  115. thing    targetArray00    nolink
  116. thing    targetArray01    nolink
  117. thing    targetArray02    nolink
  118.  
  119. thing    targetArray10    nolink
  120. thing    targetArray11    nolink
  121. thing    targetArray12    nolink
  122.  
  123. thing    targetArray20    nolink
  124. thing    targetArray21    nolink
  125. thing    targetArray22    nolink
  126.  
  127. thing    targetArray30    nolink
  128. thing    targetArray31    nolink
  129. thing    targetArray32    nolink
  130.  
  131. # ***** LOCAL THINGS ************************************************
  132.  
  133. thing    player        local
  134. thing    sender        local
  135. thing    target        local
  136.  
  137. # ***** MATERIALS ***************************************************
  138.  
  139. material    electroMat=nub_a_plate_electric.mat            local
  140. material    lightningmat0=aet_4sfx_lightning_v2_a.mat    local
  141. material    lightningmat1=aet_4sfx_lightning_v2_b.mat    local
  142. material    lightningmat2=aet_4sfx_lightning_v2_c.mat    local
  143. material    lightningmat3=aet_4sfx_lightning_v2_d.mat    local
  144. material    lightningmat4=aet_4sfx_lightning_v2_e.mat    local
  145.  
  146. # ***** SOUNDS ******************************************************
  147.  
  148. sound    strike0=aet_lightning_01.wav        local
  149. sound    strike1=aet_lightning_02.wav        local
  150. sound    strike2=aet_lightning_03.wav        local
  151. sound    strike3=aet_lightning_04.wav        local
  152. sound    drainSnd=riv_rapid_cave_a.wav        local
  153. sound    fillSnd=riv_rapid_cave2_a.wav        local
  154. sound    buttonSnd=gen_stonebutt_push_c.wav    local
  155.  
  156. # ***** BOOLS *******************************************************
  157.  
  158. int        disabled=0        local
  159. int        firstEnter=0    local
  160. int        lightning=0        local
  161.  
  162. int        toggle=0        local
  163. int        waterMoving=0    local
  164.  
  165. # ***** MISC. LOCAL VARIABLES ***************************************
  166.  
  167. int        originIndex        local
  168.  
  169. int        drainTrack=-1    local
  170.  
  171. int        open=1            local
  172. int        closed=0        local
  173.  
  174. int        index            local
  175. int        count            local
  176.  
  177. int        senderID        local
  178.  
  179. int        padAState=0        local
  180. int        padBState=0        local
  181.  
  182. int        waterLevel=2    local    # 0 = empty, 1 = mid level, 2 = full
  183.  
  184. int        curPaddle        local
  185. int        curSwitch        local
  186. int        curFrame        local
  187.  
  188. int        randInt            local
  189.  
  190. flex    countdown=0.75    local    # Speed of water draining or filling.
  191.  
  192. vector    veclight        local
  193. vector    lesslight        local
  194.  
  195. # ***** SUBROUTINES *************************************************
  196.  
  197. flex    ShowPaddles        local
  198. flex    PaddleCheck        local
  199. flex    StopLightning    local
  200.  
  201. end
  202.  
  203. # ===================================================================
  204. code
  205.  
  206. startup:
  207.  
  208. player = GetLocalPlayerThing();
  209.  
  210. # Initialize variables
  211. veclight = VectorSet(0, 0.2, 0.8);
  212. lesslight = VectorSet(0, 0.1, 0.5);
  213.  
  214. # Do stuff
  215. for (index = 0; index < 8; index = index + 1)
  216. {
  217.     SetSectorLight(twater0[index], veclight, 5); # top sector light on 
  218.     SetFaceGeoMode(surface1a[index], 0); # mid level adjoins off
  219. }
  220. for (index = 0; index < 4; index = index + 1)
  221. {
  222.     SetThingLight(paddleAtop[index], '1.0 1.0 1.0', 0.01, 1.0); # paddle lights on
  223.     SetSectorLight(bwater0[index], veclight, 5); # bottom water sector light on
  224. }
  225. for (index = 0; index < 3; index = index + 1)
  226. {
  227.     SetThingLight(drainWater0[index], '0.8 0.8 0.8', 0.01, 1.0); # drain lights on
  228. }
  229. for (index = 0; index < 2; index = index + 1)
  230. {
  231.     SetThingLight(switchA[index], '1.0 1.0 1.0', 0.01, 1.0); # switch lights on
  232.     SetSectorLight(ptsec0[index], veclight, 5); # top paddle sector light on
  233.     SetSectorLight(pbsec0[index], veclight, 5); # bottom paddle sector light on
  234. }
  235. SetSectorlight(ptsec2, lesslight, 5);
  236. SetSectorlight(pbsec2, lesslight, 5);
  237.  
  238. # Hide water 3DOs
  239. SetCollideType(h2o, 0);
  240. SetThingFlags(h2o, 0x80000);
  241. SetThingFlags(drainwater1, 0x80000);
  242. SetThingFlags(drainwater2, 0x80000);
  243.  
  244. # Start sounds
  245. Sleep(0.01);
  246. PlaySoundThing(fillSnd, spicket, 1.0, -1, -1, 0x881);
  247. drainTrack = PlaySoundThing(drainSnd, drainWater0, 0.7, 1.0, 20.0, 0x881);
  248.  
  249. return;
  250.  
  251. # -------------------------------------------------------------------
  252.  
  253. activated:
  254.  
  255. if (disabled) return;
  256. if (waterMoving) return;
  257.  
  258. # Check switches
  259. if (GetSenderID() != 3) return;
  260.  
  261. sender = GetSenderRef();
  262. if (sender == switchA)
  263. {
  264.     if (padAState < 2)
  265.         curPaddle = 0 ;
  266.     else
  267.         curPaddle = 1;
  268.  
  269.     call ShowPaddles;
  270.  
  271.     padAState = padAState + 1;
  272.     if (padAState > 3)
  273.         padAState = 0 ;
  274. }
  275. else if (sender == switchB)
  276. {
  277.     if (padBState < 2)
  278.         curPaddle = 3;
  279.     else
  280.         curPaddle = 2;
  281.  
  282.     call ShowPaddles;
  283.  
  284.     padBState = padBState + 1;
  285.     if (padBState > 3)
  286.         padBState = 0 ;
  287. }
  288.  
  289. return;
  290.  
  291. # -------------------------------------------------------------------
  292.     
  293. ShowPaddles:    
  294.  
  295. if (MakeMeStop() == -1) return;
  296. StartCutscene(1);
  297. DeselectWeaponWait(player);
  298.  
  299. PlayMode(player, 60, 0);
  300. Sleep(0.5);
  301.  
  302. curSwitch = curPaddle / 2;
  303. MoveToFrame(switchA[curSwitch], 1, 0.5);
  304. PlaySoundThing(buttonSnd, switchA[curSwitch], 1.0, -1, -1, 0x880);
  305. Sleep(0.55);
  306.  
  307. SetCameraFocus(2, camera1);
  308. SetCameraSecondaryFocus(2, paddletarget);
  309. SetCurrentCamera(2);
  310. SetCameraFOV(120, 0, 0.0);
  311.  
  312. MoveToFrame(paddleAtop[curPaddle], 1 - GetCurFrame(paddleAtop[curPaddle]), 0.5);
  313.  
  314. return;
  315.  
  316. # -------------------------------------------------------------------
  317.  
  318. arrived:
  319.  
  320. senderID = GetSenderID();
  321.  
  322. # Check paddles
  323. if (senderID == 4)
  324. {
  325.     call PaddleCheck;
  326.  
  327.     Sleep(0.5);
  328.     ResetCameraFOV(0, 0.0);
  329.     SetCurrentCamera(1);
  330.  
  331.     if (!waterMoving)
  332.     {
  333.         PlaySoundThing(buttonSnd, switchA[curSwitch], 1.0, -1, -1, 0x880);
  334.         MoveToFrame(switchA[curSwitch], 0, 1.0);
  335.     }
  336.  
  337.     Sleep(0.5);
  338.     ClearActorFlags(player, 0x200000);
  339.     EndCutscene();
  340.  
  341.     return;
  342. }
  343.  
  344. sender = GetSenderRef();
  345. curFrame = GetCurFrame(sender);
  346.  
  347. # Check water
  348. if (senderID == 5)
  349. {
  350.     waterMoving = 0;
  351.  
  352.     # Fade old drain sound & start the new one
  353.     if (drainTrack != -1)
  354.     {
  355.         StopSound(drainTrack, 0.0);
  356.     }
  357.     drainTrack = PlaySoundThing(drainSnd, drainWater0[curFrame], 0.7, 1.0, 20.0, 0x881);
  358.  
  359.     PlaySoundThing(buttonSnd, switchA[curSwitch], 1.0, -1, -1, 0x880);
  360.     MoveToFrame(switchA[curSwitch], 0, 1.0);
  361.  
  362.     if (curFrame == 0) # Top level
  363.     {
  364. #        Print("Water arrived at top");
  365.         SendMessage(lightningcog, user1);
  366.  
  367.         SetThingFlags(h2o, 0x80000);
  368.         SetThingFlags(drainWater1, 0x80000);
  369.         SetThingFlags(drainWater2, 0x80000);
  370.         ClearThingFlags(drainWater0, 0x80000);
  371.  
  372.         # Turn on adjoins and sectors
  373.         for (index = 0; index < 8; index = index + 1)
  374.         {
  375.             SetFaceGeoMode(surface0a[index], 4);
  376.             SetSectorFlags(twater0[index], 0x2);
  377.         }
  378.         SetFaceGeoMode(surface0i, 4); # One extra...
  379.     }
  380.     else if (curFrame == 1) # Middle level
  381.     {
  382. #        Print("Water arrived at middle");
  383.         SetThingFlags(h2o, 0x80000);
  384.         SetThingFlags(drainWater0, 0x80000);
  385.         SetThingFlags(drainWater2, 0x80000);
  386.         ClearThingFlags(drainWater1, 0x80000);
  387.  
  388.         for (index = 0; index < 8; index = index + 1)
  389.         {
  390.             SetFaceGeoMode(surface1a[index], 4); #middle water level adjoins on
  391.         }
  392.     }
  393.     else# if (curFrame == 2) # Bottom level
  394.     {
  395. #        Print("Water arrived at bottom");
  396.         SetThingFlags(drainWater0, 0x80000);
  397.         SetThingFlags(drainWater1, 0x80000);
  398.         ClearThingFlags(drainWater2, 0x80000);
  399.     }
  400. }
  401. return;
  402.  
  403. # -------------------------------------------------------------------
  404.  
  405. entered:
  406.  
  407. if (GetSourceRef() != player) return;
  408.  
  409. senderID = GetSenderID();
  410. sender = GetSenderRef();
  411.  
  412. # If player enters pool while it's full, kill him
  413. if (senderID == 1)
  414. {
  415.     if (waterLevel != 2) return;
  416.     
  417.     DamageThing(player, 1000, 0x02, 0);
  418.     toggle = 1;
  419. }
  420.  
  421. # If player falls into pool, kill him
  422. if (senderID == 2)
  423. {
  424.     DamageThing(player, 1000, 0x02, 0);
  425.     return;
  426. }
  427.  
  428. if (firstEnter != 0) return;
  429.  
  430. if (sender == trigger)
  431. {
  432.     firstEnter = 1;
  433.     lightning = 1;
  434.  
  435.     SetTimer(Rand() * 2.5);
  436.     MaterialAnim(electroMat, 3.8, 0x1); 
  437. }
  438.  
  439. return;
  440.  
  441. # -------------------------------------------------------------------
  442.  
  443. taken:
  444.  
  445. if (GetSenderRef() != IMP4) return;
  446. {
  447.     # Once the IMP is taken, everything shuts down.
  448.     disabled = 1;
  449.     SendMessage(lightningcog, user2);
  450. }
  451.  
  452. return;
  453.  
  454. # -------------------------------------------------------------------
  455.  
  456. timer:
  457.  
  458. # Lightning code
  459. if (toggle == 0)
  460. {
  461.     for (count = 2; count <= RandBetween(2, 5); count = count + 1)
  462.     {
  463.         originIndex = RandBetween(0, 3);
  464.         randInt = RandBetween(0, 2);
  465.         if (originIndex == 0)
  466.         {
  467.             target = targetArray00[randInt];
  468.         }
  469.         else if (originIndex == 1)
  470.         {
  471.             target = targetArray10[randInt];
  472.         }
  473.         else if (originIndex == 2)
  474.         {
  475.             target = targetArray20[randInt];
  476.         }
  477.         else if (originIndex == 3)
  478.         {
  479.             target = targetArray30[randInt];
  480.         }
  481.  
  482.         CreatePolylineThing(origin0[originIndex], target, '0 0 0', lightningmat0[RandBetween(0, 4)], 0.1, 0.1, 0.05);
  483.         PlaySoundThing(strike0[RandBetween(0, 3)], target, 0.8, 5, 15, 0x80);
  484.         Sleep(0.05);
  485.     }
  486. }
  487. else
  488. {
  489.     currentSector = GetThingSector(player);
  490.     randInt = RandBetween(0, 2);
  491.  
  492.     if (currentSector == twater0)
  493.     {
  494.         originIndex = 0;
  495.         target = targetArray00[randInt];
  496.     }
  497.     else if (currentSector == twater1)
  498.     {
  499.         originIndex = 1;
  500.         target = targetArray10[randInt];
  501.     }
  502.     else if (currentSector == twater2)
  503.     {
  504.         originIndex = 2;
  505.         target = targetArray20[randInt];
  506.     }
  507.     else if (currentSector == twater3)
  508.     {
  509.         originIndex = 3;
  510.         target = targetArray30[randInt];
  511.     }
  512.  
  513.     CreatePolylineThing(origin0[originIndex], player, '0 0 0', lightningmat0[RandBetween(0, 4)], 0.1, 0.1, 0.15);
  514.     CreatePolylineThing(player, target, '0 0 0', lightningmat0[RandBetween(0, 4)], 0.1, 0.1, 0.15);
  515.     PlaySoundThing(strike0[RandBetween(0, 3)], target, 1.0, 5, 10, 0x80);
  516. }
  517.  
  518. if (lightning == 1)
  519. {
  520.     SetTimer(Rand() * 2.5);
  521. }
  522.  
  523. return;
  524.  
  525. # -------------------------------------------------------------------
  526.  
  527. PaddleCheck:
  528.  
  529. #DebugLocalSymbols("PaddleCheck");
  530. if (GetCurFrame(paddleAbottom) == 1) # Bottom right is open
  531. {
  532.     if (GetCurFrame(paddleBbottom) == 1) # Bottom left is open
  533.     {
  534.         waterMoving = 1;
  535.         waterLevel = 0;
  536.  
  537.         SetCameraFocus(2, camera0);
  538.         SetCameraSecondaryFocus(2, h2o);
  539.         SetCurrentCamera(2);
  540.         #SetCameraFOV(90, 1, 5.0);
  541.         SetCameraFOV(90, 0, 0.0);
  542.  
  543.         for (index = 0; index < 8; index = index + 1)
  544.         {
  545.             SetFaceGeoMode(surface0a[index], 0); # surface adjoins off
  546.             SetFaceGeoMode(surface1a[index], 0); # mid level adjoins off
  547.             ClearSectorFlags(twater0[index], 0x2); # top sectors off
  548.             SetSectorLight(twater0[index], '0 0 0', 5); # top sector light off
  549.         }
  550.         SetFaceGeoMode(surface0i, 0); # One extra...
  551.  
  552.         for (index = 0; index < 4; index = index + 1)
  553.         {
  554.             ClearSectorFlags(bwater0[index], 0x2); # bottom sectors off
  555.             SetSectorLight(bwater0[index], '0 0 0', 5); # bottom sector light off
  556.         }
  557.  
  558.         for (index = 0; index < 3; index = index + 1)
  559.         {
  560.             SetSectorLight(ptsec0[index], '0 0 0', 5); # top paddle sector light off
  561.             SetSectorLight(pbsec0[index], '0 0 0', 5); # bottom paddle sector light off
  562.         }
  563.  
  564.         # Move water to bottom position
  565.         ClearThingFlags(h2o, 0x80000);
  566.         MoveToFrame(h2o, 2, countdown);
  567.  
  568.         if (drainTrack != -1)
  569.         {
  570.             StopSound(drainTrack, 2.0);
  571.         }
  572.         drainTrack = PlaySoundThing(drainSnd, h2o, 0.7, 1.0, 18.0, 0x881);
  573.  
  574.         # Stop lightning as water passes
  575.         Sleep(2.5);
  576.         Call StopLightning;
  577.         Sleep(12.0);                            #was 10.0
  578.         
  579.         return;
  580.     }
  581. }
  582. else if (GetCurFrame(paddleAtop) == 1) # Top right is open
  583. {
  584.     if (GetCurFrame(paddleBtop) == 1) # Top left is open
  585.     {
  586.         if (waterLevel == 0) return;
  587.  
  588.         waterMoving = 1;
  589.         waterLevel = 1;
  590.         
  591.         SetCameraFocus(2, camera0);
  592.         SetCameraSecondaryFocus(2, h2o);
  593.         SetCurrentCamera(2);
  594.         SetCameraFOV(90, 1, 5.0);
  595.         
  596.         for (index = 0; index < 8; index = index + 1)
  597.         {
  598.             SetFaceGeoMode(surface0a[index], 0); # surface adjoins off
  599.             ClearSectorFlags(twater0[index], 0x2); # top sectors off
  600.             SetSectorLight(twater0[index], '0 0 0', 35); # top sector light off
  601.         }
  602.         SetFaceGeoMode(surface0i, 0); # One extra...
  603.  
  604.         for (index = 0; index < 4; index = index + 1)
  605.         {
  606.             SetSectorFlags(bwater0[index], 0x2); # bottom water sectors on
  607.             SetSectorLight(bwater0[index], veclight, 15); # bottom sector light on
  608.         }
  609.  
  610.         for (index = 0; index < 3; index = index + 1)
  611.         {
  612.             SetSectorLight(ptsec0[index], '0 0 0', 35); # top paddle sector light off
  613.         }
  614.  
  615.         SetSectorLight(pbsec0, veclight, 15); # bottom paddle sector light on
  616.         SetSectorLight(pbsec0, veclight, 15);
  617.         SetSectorLight(pbsec0, lesslight, 15);
  618.  
  619.         # Turn on water 3do and move it to center position...
  620.         ClearThingFlags(h2o, 0x80000);
  621.         MoveToFrame(h2o, 1, countdown);
  622.  
  623.         if (drainTrack != -1)
  624.         {
  625.             StopSound(drainTrack, 2.0);
  626.         }
  627.         drainTrack = PlaySoundThing(drainSnd, h2o, 0.4, 1.0, 20.0, 0x881);
  628.  
  629.         # Stop lightning as water passes
  630.         Sleep(2.5);
  631.         Call StopLightning;
  632.         Sleep(8.5);                            #was 7.0
  633.  
  634.         return;
  635.     }
  636. }
  637.  
  638. # If we made it this far, neither drain is open
  639. if (waterLevel != 2) # water is down, so bring it back up
  640. {
  641.     waterMoving = 1;
  642.     waterLevel = 2;
  643.  
  644.     SetCameraFocus(2, camera0);
  645.     SetCameraSecondaryFocus(2, h2o);
  646.     SetCurrentCamera(2);
  647.     SetCameraFOV(90, 1, 5.0);
  648.     
  649.     for (index = 0; index < 8; index = index + 1)
  650.     {
  651.         SetFaceGeoMode(surface1a[index], 0); # mid level adjoins off
  652.         SetSectorFlags(twater0[index], 0x2); # top sectors on
  653.         SetSectorLight(twater0[index], veclight, 5); # top sector light on
  654.     }
  655.  
  656.     for (index = 0; index < 4; index = index + 1)
  657.     {
  658.         SetSectorFlags(bwater0[index], 0x2); # bottom water sectors on
  659.         SetSectorLight(bwater0[index], veclight, 5); # bottom water sector light on
  660.     }
  661.  
  662.     SetSectorlight(pbsec0, veclight, 5); # bottom paddle sector light on
  663.     SetSectorlight(pbsec1, veclight, 5);
  664.     SetSectorlight(pbsec2, lesslight, 5);
  665.  
  666.     SetSectorlight(ptsec0, veclight, 5); # top paddle sector light on
  667.     SetSectorlight(ptsec1, veclight, 5);
  668.     SetSectorlight(ptsec2, lesslight, 5);
  669.  
  670.     # ...turn on water 3do and move it to top position...
  671.     ClearThingFlags(h2o, 0x80000);
  672.     MoveToFrame(h2o, 0, countdown * 1.5);
  673.  
  674.     if (drainTrack != -1)
  675.     {
  676.         StopSound(drainTrack, 2.0);
  677.     }
  678.         
  679.     # Restart lightning as water passes
  680.     if (GetCurFrame(h2o) == 2)
  681.     {
  682.         drainTrack = PlaySoundThing(drainSnd, h2o, 0.7, 1.0, 30.0, 0x881);
  683.         Sleep(11.3);
  684.     }
  685.     else
  686.     {
  687.         drainTrack = PlaySoundThing(drainSnd, h2o, 0.5, 0.1, 20.0, 0x881);
  688.         Sleep(4.8);
  689.     }
  690.     
  691. #    Print("Starting mat track");
  692.     MaterialAnim(electroMat, 3.8, 0x1);
  693.     SetTimer(Rand() * 2.5);
  694.     Sleep(2.5);                    #was 1.0
  695. }
  696. return;
  697.  
  698. # -------------------------------------------------------------------
  699.  
  700. StopLightning:
  701.  
  702. lightning = 0;
  703.  
  704. #Print("Stopping mat track");
  705. StopMaterialAnim(electroMat); # stop animating surfaces
  706. SetMaterialCel(electroMat, 0); # reset cel
  707.  
  708. SendMessage(lightningcog, user0);
  709. SetTimer(0.0);
  710.  
  711. return;
  712.  
  713. end
  714.